#pragma once
#include "Types.h"
#include <string>
#include "rect.h"
#include "vector2.h"

//Texture validitly variables
#define TEXTURE_OK 0
#define TEXTURE_ERR_GLINTERNAL 1
#define TEXTURE_ERR_NULL 2
#define TEXTURE_ERR_UNLOADED 3
#define TEXTURE_ERR_FILE 4

class Surface;
struct SDL_Surface;
class Texture
{
public:
	Texture();
	Texture(const Texture &tex);
	Texture operator=(const Texture &tex);
	Texture(Surface *pSurface);
	Texture(const std::string &filename);
	~Texture();
	void BindTexture();
	void FreeTexture();
	bool IsValidTexture();
	uint Width();
	uint Heigth();
	int GetValidator() const { return (*m_validator); };
	uint GetTextureName() const;
	Rect GetTextureDimensionsRectangle();
	vector2 GetTextureDimensionsVector();

public:
	static bool CreateFromILImage(uint imageName, Texture *pTexture);

protected:
	void _LoadGlTexture(Surface *pSurface);
	void _LoadGlTextureFromPixels32(void *pixels, uint width, uint height);
	void _LoadGlTexture(const std::string &filename);

protected:
	boost::shared_ptr<int> m_validator;
	uint m_nWidth;
	uint m_nHeight;
	bool m_bValidTexture;
	uint m_nTextureName;
};

typedef boost::shared_ptr<Texture> TexturePtr;